package com.jt.www.dao.mapper.messageinfo;


import com.jt.www.dao.BaseMapper;
import com.jt.www.model.entity.MessageInfoEntity;
import com.jt.www.model.vo.MessageNumVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public interface MessageInfoEntityMapper extends BaseMapper<MessageInfoEntity> {

//    MessageInfoEntity searchLatestUnreadMessageByUser(@Param("targetUser") String targetUser);

//    @Update(value = "update t_message_info  set notice_state= 1,update_time=now() where id = #{id}")
//    int updateNoticeStatetById(@Param("id") Integer id);

//    @Update(value = "update t_message_info  set is_deleted= 1,update_time=now() where id = #{id}")
//    int deleteMessageInfoById(Integer id);

    @Select("SELECT message_type,COUNT(id) as message_type FROM t_message_info  WHERE target_user = #{targetUser} AND notice_state = 0  GROUP BY message_type")
    @Results({
            @Result(property = "messageType", column = "message_type"),
            @Result(property = "messageNum", column = "message_type"),
    })
    public List<MessageNumVo> queryToDoItemNum(@Param("targetUser") String targetUser);


}
